//
//  NCMotifypasswordVC.m
//  NursingAssociation
//
//  Created by wsj2015 on 2017/3/1.
//  Copyright © 2017年 wsj2015. All rights reserved.
//

#import "NCMotifypasswordVC.h"
#import "NSString+Utilities.h"
@interface NCMotifypasswordVC ()
@property (weak, nonatomic) IBOutlet UITextField *oldPwdTf;
@property (weak, nonatomic) IBOutlet UITextField *pwdTf;

@property (weak, nonatomic) IBOutlet UITextField *confirmPwdTf;

@end

@implementation NCMotifypasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"修改密码";
    self.view.backgroundColor = kTableView_bg;
}

- (IBAction)confirmAction:(id)sender {
    if ([self.oldPwdTf.text isEmpty]) {
        cwqAlertMessage(@"密码不能空");
        return ;
    }
    
    
    if ([self.pwdTf.text isEmpty] || self.pwdTf.text.length <6 || self.pwdTf.text.length > 16) {
        cwqAlertMessage(@"密码不合法");
        return ;
    }
    if (![self.confirmPwdTf.text isEqualToString:self.pwdTf.text]) {
        cwqAlertMessage(@"两次密码不一致");
        return ;
    }
    cwqHud(self.view);
    weakSelf_define;
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"oldPassword"] = self.oldPwdTf.text;
    
    params[@"newPassword"] = self.pwdTf.text;
    
    [[HELNetworkManager sharedMg] PUT:helModifyUrl parameters:params progress:nil success:^(id response) {
        [hud hide:YES];
        if ([response[@"data"] isKindOfClass:[NSString class]]) {
            if ([response[@"data"] containsString:@"修改密码成功"]) {
                cwqAlertMessage(response[@"data"]);
                [weakSelf.navigationController popViewControllerAnimated:YES];
            }
        }
        
    } failure:^(NSString *err) {
        [hud hide:YES];
    }];
    
    

}







@end
